package com.example.dao;

import com.example.entity.ClassInfo;
import com.example.entity.ZhuanyeInfo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;
import java.util.Vector;

@Repository
public interface ClassInfoDao extends Mapper<ClassInfo> {
    @Select("select * from class_info where name=#{name}")
    ClassInfo findByName(String name);




    @Select("select * from class_info")
    List<ClassInfo> selectAllClass();

    @Update("UPDATE class_info " +
            "SET name = #{name}, decription = #{decription}, zhuanyeid = #{zhuanyeid} , score = #{score}, teacherid = #{teacherid}, kaiban = #{kaiban}, time = #{time}, location = #{location} , yixuan = #{yixuan} " +" "+//这个空格必须加，否则会 报错
            "WHERE id = #{id}")
    void updateById(@Param("id") long id, @Param("name")String name, @Param("decription")String decription, @Param("zhuanyeid") Long zhuanyeid, @Param("score") Integer score, @Param("teacherid")Long teacherid, @Param("kaiban")Integer kaiban,@Param("time")String time, @Param("location")String location, @Param("yixuan")Integer yixuan);

    @Delete("DELETE FROM class_info WHERE id = #{id}")
    void deleteById(Long id);

    @Select("select * from class_info")
    List<ClassInfo> selectAllTeacher();

    @Select("select * from class_info where name like concat('%',#{name},'%')")
    List<ClassInfo> findByNamePage(String name);

    @Select("select * from class_info where name=#{name} and teacherid = #{teacherid} limit 1")
    ClassInfo findByNameAndTeacher(@Param("name") String name,@Param("teacherid") Long teacherid);


}
